﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using DBLayer;

namespace BALayer
{
    public class DBHocSinh
    {
        DAL db = null;
        public DBHocSinh()
        {
            db = new DAL();
        }
        //Lay Hoc Sinh
        public DataSet LayHocSinh()
        {
            return db.ExecuteQueryDataSet("Select * From HocSinh", CommandType.Text, null);
        }
        //Them Hoc Sinh
        public bool ThemHocSinh(ref string err, string MaHS, string HoTen, string GioiTinh, DateTime NgaySinh, string MaLop, string QueQuan, string HoTenCha, string NgheNghiepCha, string HoTenMe, string NgheNghiepMe, string DiaChi, string SDTLL)
        {
            return db.MyExecuteNonQuery("SpThemHocSinh", CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaHS", MaHS),
                new SqlParameter("@HoTen", HoTen),
                new SqlParameter("@GioiTinh", GioiTinh),
                new SqlParameter("@NgaySinh", NgaySinh),
                new SqlParameter("@MaLop", MaLop),
                new SqlParameter("@QueQuan", QueQuan),
                new SqlParameter("@HoTenCha", HoTenCha),
                new SqlParameter("@NgheNghiepCha", NgheNghiepCha),
                new SqlParameter("@HoTenMe", HoTenMe),
                new SqlParameter("@NgheNghiepMe", NgheNghiepMe),
                new SqlParameter("@DiaChi", DiaChi),
                new SqlParameter("@SDTLL", SDTLL));
        }
        //Xoa Hoc Sinh
        public bool XoaHocSinh(ref string err, string MaHS)
        {
            return db.MyExecuteNonQuery("SpXoaHocSinh", CommandType.StoredProcedure, ref err, new SqlParameter("@MaHS", MaHS));
        }
        //Cap nhat Hoc Sinh

        public bool CapNhatHocSinh(ref string err, string MaHS, string HoTen, string GioiTinh, DateTime NgaySinh, string MaLop, string QueQuan, string HoTenCha, string NgheNghiepCha, string HoTenMe, string NgheNghiepMe, string DiaChi, string SDTLL)
        {
            return db.MyExecuteNonQuery("SpCapNhatHocSinh", CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaHS", MaHS),
                new SqlParameter("@HoTen", HoTen),
                new SqlParameter("@GioiTinh", GioiTinh),
                new SqlParameter("@NgaySinh", NgaySinh),
                new SqlParameter("@MaLop", MaLop),
                new SqlParameter("@QueQuan", QueQuan),
                new SqlParameter("@HoTenCha", HoTenCha),
                new SqlParameter("@NgheNghiepCha", NgheNghiepCha),
                new SqlParameter("@HoTenMe", HoTenMe),
                new SqlParameter("@NgheNghiepMe", NgheNghiepMe),
                new SqlParameter("@DiaChi", DiaChi),
                new SqlParameter("@SDTLL", SDTLL));
        }
    }
}
